package com.ruoyi.system.controller;

import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.security.annotation.PreAuthorize;
import com.ruoyi.system.domain.SysFaceLog;
import com.ruoyi.system.service.ISysFaceLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 人脸识别Controller
 * 
 * @author yfkj
 * @date 2022-01-19
 */
@RestController
@RequestMapping("/system/SysFacelog")
public class SysFaceLogController extends com.ruoyi.common.core.web.controller.BaseController
{
    @Autowired
    private ISysFaceLogService sysFaceLogService;

    /**
     * 查询人脸识别列表
     */
    @PreAuthorize
    //@PreAuthorize(hasPermi = "system:SysFacelog:list")
    @GetMapping("/list")
    public com.ruoyi.common.core.web.page.TableDataInfo list(SysFaceLog sysFaceLog)
    {
        startPage();
        List<SysFaceLog> list = sysFaceLogService.selectSysFaceLogList(sysFaceLog);
        return getDataTable(list);
    }

    /**
     * 导出人脸识别列表
     */
    @PreAuthorize
    //@PreAuthorize(hasPermi = "system:SysFacelog:export")
    @Log(title = "人脸识别", businessType = BusinessType.EXPORT)
    @PostMapping(value="/export", produces = "application/octet-stream")
    public void export(HttpServletResponse response, SysFaceLog sysFaceLog) throws IOException
    {
        List<SysFaceLog> list = sysFaceLogService.selectSysFaceLogList(sysFaceLog);
        com.ruoyi.common.core.utils.poi.ExcelUtil<SysFaceLog> util = new com.ruoyi.common.core.utils.poi.ExcelUtil<SysFaceLog>(SysFaceLog.class);
        util.exportExcel(response, list, "人脸识别数据");
    }

    /**
     * 获取人脸识别详细信息
     */
    @PreAuthorize
    //@PreAuthorize(hasPermi = "system:SysFacelog:query")
    @GetMapping(value = "/{sysFaceId}")
    public com.ruoyi.common.core.web.domain.AjaxResult getInfo(@PathVariable("sysFaceId") Long sysFaceId)
    {
        return com.ruoyi.common.core.web.domain.AjaxResult.success(sysFaceLogService.selectSysFaceLogBySysFaceId(sysFaceId));
    }

    /**
     * 新增人脸识别
     */
    @PreAuthorize
    //@PreAuthorize(hasPermi = "system:SysFacelog:add")
    @Log(title = "人脸识别", businessType = BusinessType.INSERT)
    @PostMapping
    public com.ruoyi.common.core.web.domain.AjaxResult add(@RequestBody SysFaceLog sysFaceLog)
    {
        return toAjax(sysFaceLogService.insertSysFaceLog(sysFaceLog));
    }

    /**
     * 修改人脸识别
     */
    @PreAuthorize
    //@PreAuthorize(hasPermi = "system:SysFacelog:edit")
    @Log(title = "人脸识别", businessType = BusinessType.UPDATE)
    @PutMapping
    public com.ruoyi.common.core.web.domain.AjaxResult edit(@RequestBody SysFaceLog sysFaceLog)
    {
        return toAjax(sysFaceLogService.updateSysFaceLog(sysFaceLog));
    }

    /**
     * 删除人脸识别
     */
    @PreAuthorize
    //@PreAuthorize(hasPermi = "system:SysFacelog:remove")
    @Log(title = "人脸识别", businessType = BusinessType.DELETE)
	@DeleteMapping("/{sysFaceIds}")
    public com.ruoyi.common.core.web.domain.AjaxResult remove(@PathVariable Long[] sysFaceIds)
    {
        return toAjax(sysFaceLogService.deleteSysFaceLogBySysFaceIds(sysFaceIds));
    }
}
